<template>
    <el-dialog title="导出" :visible.sync="getDialogStatus.stDownFile">
        <el-input placeholder="请输入文件名" v-model="filename"></el-input>

        <div slot="footer" class="dialog-footer">
            <el-button @click="closeAllDialog">取 消</el-button>
            <el-button type="primary" @click.stop="exportFile()">确 定</el-button>
        </div>
    </el-dialog>
</template>

<script>
import {mapMutations,mapGetters} from 'vuex';
export default {
    props:{
        
    },
    data() {
        return {
            filename:'',
        };
    },
    computed:{
        ...mapGetters(['getDialogStatus','getCurrentActiveTable'])
    },
    watch:{
        
    },
    mounted(){
        
    },
    methods:{
        ...mapMutations(['setDialogStatus','closeAllDialog']),
        exportFile(){
            if(!this.getCurrentActiveTable){
                console.log('fff');
                this.$message({
                    message: '没有可用的表格！',
                    type: 'warning'
                });
                this.closeAllDialog();
                return;
            }else{
                if(this.filename.replace(/\s+/g,"")==""){
                    this.$message({
                        message: '文件名不能为空！',
                        type: 'warning'
                    });
                    return;
                }
                let exportFilePlugin=this.getCurrentActiveTable.hs.getPlugin('exportFile');
                exportFilePlugin.downloadFile('csv',{
                    bom: false,
                    columnDelimiter: ',',
                    columnHeaders: true,
                    exportHiddenColumns: true,
                    exportHiddenRows: true,
                    fileExtension: 'csv',
                    filename: this.filename,
                    mimeType: 'text/csv',
                    rowDelimiter: '\r\n',
                    rowHeaders: true
                })
            }
        }
    }
}
</script>

<style>

</style>
